package com.ibiaoke.boss.controller;

import com.ibiaoke.common.base.BaseController;
import com.ibiaoke.common.consts.CommonConsts;
import com.ibiaoke.common.consts.WeChatConsts;
import com.ibiaoke.common.response.Res;
import com.ibiaoke.customer.entity.Customer;
import com.ibiaoke.customer.entity.vo.CustomerVO;
import com.ibiaoke.customer.entity.vo.DepositVO;
import com.ibiaoke.customer.service.CustomerService;
import com.ibiaoke.customer.service.DepositService;
import com.ibiaoke.customer.service.ThirdPartLoginService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by huhaichao on 2017/6/23.
 */
@Controller
public class WxCustomerController extends BaseController {

    @Autowired
    private CustomerService customerService;

    @Autowired
    private ThirdPartLoginService thirdPartLoginService;

    /**
     * 获取门店列表
     *
     * @return
     */
    @RequestMapping("/getUserInfo")
    @ResponseBody
    public Res getUserInfo() {
        Customer customer = getLoginUser();
        customer = customerService.getCustomerInfo(customer.getCustomerId());
        CustomerVO customerVO = new CustomerVO();
        BeanUtils.copyProperties(customer, customerVO);
        return Res.create().addResponse("customerInfo", customerVO);
    }

    @RequestMapping("/editUserMobile")
    @ResponseBody
    public Res editUserMobile(CustomerVO customerVO) {
        Customer customer = getLoginUser();
        customerService.editUserMobile(customer,customerVO);
        thirdPartLoginService.editUserMobile(customer,customerVO);
        getSession().invalidate();
        return Res.create();
    }
}
